use train_edu dom_job spell_length_ft wage_ft year potential_experience train_occ using "$temp/analysis_pt_new", clear

keep if inlist(train_edu,1,3)
keep if dom_job == 1
drop train_edu dom_job 

gen log_earning_ft = log(spell_length_ft * wage_ft)

reg log_earning_ft i.year i.potential_experience

predict u_hat, res

collapse (mean) u_hat, by(train_occ)

sum u_hat, d
gen high_skill = (u_hat >= r(p50))
tab high_skill, mis

drop u_hat
compress

save "$temp/high_skill", replace
cap log close